/*****************************************************************************/
/**
 *  @file   ParticleDraw.cpp
 *  @author Allan Lorant, Naohisa Sakamoto
 */
/*----------------------------------------------------------------------------
 *
 *  Copyright (c) Visualization Laboratory, Kyoto University.
 *  All rights reserved.
 *  See http://www.viz.media.kyoto-u.ac.jp/kvs/copyright/ for details.
 *
 *  $Id$
 */
/*****************************************************************************/
#include <kvs/glut/Application>
#include <kvs/glut/Screen>
#include <kvs/ParticleVolumeRenderer>
#include <kvs/glew/ParticleVolumeRenderer>
#include "ParticleDraw.h"


int main( int argc, char** argv )
{
    kvs::glut::Application app( argc, argv );
    kvs::glut::Screen screen( &app );

    const int repeat = std::atoi( argv[1] );
    const int gpu = std::atoi( argv[2] );
    const int lod = std::atoi( argv[3] );

    ParticleDraw::Interface interface;
    kvs::PointObject* object = interface.recv();

    if ( gpu == 0 )
    {
        int subpixel = std::sqrt( repeat );
        kvs::ParticleVolumeRenderer* renderer = new kvs::ParticleVolumeRenderer();
        renderer->setSubpixelLevel( subpixel );
        screen.registerObject( object, renderer );
    }
    else if ( gpu == 1 )
    {
        kvs::glew::ParticleVolumeRenderer* renderer = new kvs::glew::ParticleVolumeRenderer();
        renderer->setSubpixelLevel( 1 );
        renderer->setRepetitionLevel( repeat );
        if ( lod == 1 ) renderer->enableLODControl();
        screen.registerObject( object, renderer );
    }

    screen.setTitle( "ParticleDraw" );
    screen.setGeometry( 0, 0, 800, 600 );
    screen.show();

    return app.run();
}
